package com.warren.auth.handler;



import com.warren.auth.utils.JSONAuthentication;
import com.warren.response.Result;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author warren
 * @date 2021/3/28 0028 20:19
 * @Description
 **/
@Component("myAuthenticationSuccessHandler")
public class MyAuthenticationSuccessHandler extends JSONAuthentication implements AuthenticationSuccessHandler {
    @Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException, IOException {
        //只需要以json的格式返回一个提示就行了
        //Result类的Json数据
        Result result = Result.ok().message("登录成功");


        this.WriteJSON(request,response,result);
    }
}
